CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld
OBJCOPY = arm-none-eabi-objcopy
OBJDUMP = arm-none-eabi-objdump
CFLAGS = -mcpu=cortex-a9 -marm -nostdlib -g

all: main.bin

main.bin: main.elf
	$(OBJCOPY) -O binary main.elf main.bin
	$(OBJDUMP) -D main.elf > main.list

main.elf: startup.o main.o ascfont.o
	$(LD) -T linker.ld startup.o main.o ascfont.o -o main.elf

startup.o: startup.s
	$(CC) $(CFLAGS) -c startup.s -o startup.o

main.o: main.c
	$(CC) $(CFLAGS) -c main.c -o main.o


%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@	



clean:
	rm -f *.o *.elf *.bin

run: main.bin
	qemu-system-arm -M realview-pbx-a9 -kernel main.elf -serial stdio